<?php
/**
 * KePHP, Keep PHP easy!
 */

namespace CSService\Model\Project;

use Ke\Adm\Model;

/**
 * Class Project
 * tableName project
 *
 * // class properties
 * @property int    $id         id
 * @property string $name       项目名称
 * @property string $repo_type  仓库类型
 * @property string $repo_url   仓库url
 * @property string $dir        项目目录
 * @property string $username   账号
 * @property string $password   密码
 * @property int    $created_at 创建时间
 * @property int    $updated_at 更新时间
 * // class properties
 */
class Project extends Model
{

	protected static $pk = 'id';

	protected static $pkAutoInc = true;

	protected static $columns = [
		'name'      => ['edit' => 'text', 'require' => 1, 'unique' => 1],
		'repo_type' => ['edit' => 'radio', 'default' => 'git'],
		'repo_url'  => ['edit' => 'url', 'require' => 1],
		'username'  => ['edit' => 'text'],
		'password'  => ['edit' => 'text'],
		'dir'       => ['edit' => 'text', 'require' => 1],
	];

	public static function dbColumns()
	{
		// database columns
		// generated as 2016-02-01 22:52:19
		return [
			'id'         => ['int' => 1, 'pk' => 1, 'autoInc' => 1],
			'name'       => ['label' => '项目名称', 'max' => 32],
			'repo_type'  => ['label' => '仓库类型', 'options' => ['svn' => 'svn', 'git' => 'git']],
			'repo_url'   => ['label' => '仓库url', 'max' => 128],
			'dir'        => ['label' => '项目目录', 'max' => 128],
			'username'   => ['label' => '账号', 'max' => 64],
			'password'   => ['label' => '密码', 'max' => 64],
			'created_at' => ['label' => '创建时间', 'timestamp' => 1, self::ON_CREATE => 'now'],
			'updated_at' => ['label' => '更新时间', 'timestamp' => 1, self::ON_UPDATE => 'now'],
		];
		// database columns
	}

}
